package com.yanqu.road.server.cmd.activity.doublespring;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.DoubleSpringProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.doublespring.CrossDoubleSpringActivity;
import com.yanqu.road.server.manager.activity.doublespring.CrossDoubleSpringActivityMgr;
import com.yanqu.road.server.manager.activity.doublespring.pb.CrossDoubleSpringActivityPb;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = Protocol.C_CROSS_DOUBLE_SPRING_QUERY_USER_BASE, desc = "踏春游记-查询玩家基础数据返回")
public class CrossDoubleSpringQueryUserBaseCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        DoubleSpringProto.DoubleSpringServerToCrossQueryUserReturnReqMsg reqMsg = DoubleSpringProto.DoubleSpringServerToCrossQueryUserReturnReqMsg.parseFrom(packet.getBytes());
        CrossDoubleSpringActivity activity = CrossDoubleSpringActivityMgr.getActivity(reqMsg.getActivityId());
        if (activity == null) {
            if (reqMsg.getUserId() != 0 && reqMsg.getServerId() != 0) {
                DoubleSpringProto.DoubleSpringQueryUserRespMsg.Builder respMsg = DoubleSpringProto.DoubleSpringQueryUserRespMsg.newBuilder();
                respMsg.setRet(GameErrorCode.E_DOUBLE_SPRING_ACTIVITY_NOT_EXIST);
                MessageHelper.sendPacket(reqMsg.getServerId(), reqMsg.getUserId(), YanQuMessageUtils.buildMessage(Protocol.U_DOUBLE_SPRING_QUERY_USER, respMsg));
            }
            return;
        }
        //查询玩家-区服返回
       activity.queryUserServerReturn(reqMsg);
    }

    @Override
    public void sendData() {

    }
}
